So far, we've been using various types of communication without realizing what protocols they use, and this class was about explaining precisely that. In my final MDEF project, I'm going to use a few of them to accomplish what I want.
In the Asynchronous communication (there are no time constraints, and often there is less speed):
- RX and TX, which is the most common way of serial communication. In my project, the DFPlayer Mini connects to Arduino through RX and TX and sends the data to the speaker. I have to say that at the beginning (way before this class), I had a hard time connecting everything because I didn't know RX should've been connected to TX in Arduino and TX to RX. It took me a long while until I realized this. It is important to note that in this type of communication, that "both ends of the communication need to agree on some topics, being the speed the most important one (known as baud rate)." To read more.
On the other hand through Synchronous communication (here, timing and speed are essential) -On this side, I'll be using the I2C protocol, which stands for "Inter-integrated Circuit and "it is intended to allow multiple slave digital integrated circuits to communicate with the master chip". So what I understand from this is that my RGB sensor will send through the SDA bus the data signal and though the SCL bus the timing. In this protocol, the first thing that happens is that "the master sends a start sequence. This will alert all the slave devices on the bus that a transaction is starting, and they should listen in case it is for them. Next, the master will send out the device address. The slave that matches this address will continue with the transaction. Any others will ignore the rest of this transaction and wait for the next" or until they match. Then after the slave devices are addressed, the master sends an internal location or register number where it wishes to write or read from.
Apart from this class, our assignment consisted of documenting the interaction that happened the day after. Óscar built a DIY network using a Raspberry-Pi, MQTT, and Node-red. "Here the instructions to build a network like this" And we had to connect to the network using a NODE-MCU (this is what I used), a Barduino, or an ESP8266 Wi-fi microchip. The first thing we had to do was connect to the network. For this, I needed to download the "ESP8266 Library" for Arduino, which I found in this Github. And then copy-paste the SSID, password, server, user, etc.. as well as the code, the professors sent us through email. After this, I just had to follow the instructions and see what Input and Output I wanted to interact with.
Through Node-Red, Óscar can connect the data. So, for example, the input data I sent would be interacting with someone else's' output.
At first, we had a hard time connecting. In my case, an error kept coming up. It seemed I wasn't sending anything, and it turned out to be that I had a typing error, so after changing, it worked out fine, and I finally connected to the network. I was using a potentiometer as an input, and a LED to the output. After this, I asked Óscar to connect Arman's input to my output. It sometimes worked, others didn't. The data was updated every 5 seconds.
Sending data with a potentiometer (I'm the purple line) and receiving data.